//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ruoyi.socket.util.midr;


import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.ruoyi.socket.util.midr.hl7.Field;
import com.ruoyi.socket.util.midr.hl7.Message;
import com.ruoyi.socket.util.midr.hl7.Segment;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;

class Parsehl7 {
    Parsehl7() {
    }

    private static String a(String var0) {
        HashMap var1;
        (var1 = new HashMap()).put("MDC_DIM_BEAT_PER_MIN", "Beats/Minute");
        var1.put("MDC_DIM_PERCENT", "%");
        var1.put("MDC_DIM_MMHG", "mmHg");
        var1.put("MDC_DIM_KILO_PASCAL", "kPa");
        var1.put("MDC_DIM_MILLI_BAR", "mbar");
        var1.put("MNDRY_DIM_MILLI_L_PER_MILLI_BAR", "ml/mbar");
        var1.put("MNDRY_DIM_MILLI_BAR_PER_L_PER_SEC", "mbar/l/s");
        var1.put("MDC_DIM_HECTO_PASCAL", "hPa");
        var1.put("MDC_DIM_KILO_CAL_PER_DAY", "Kcal/day");
        var1.put("MDC_DIM_KILO_G", "kilograms(kg)");
        var1.put("MDC_DIM_LB", "pounds");
        var1.put("MDC_DIM_OZ", "ounces");
        var1.put("MDC_DIM_CENTI_M", "centimeters(cm)");
        var1.put("MDC_DIM_MILLI_M", "millimeters(mm)");
        var1.put("MDC_DIM_FOOT", "feet");
        var1.put("MDC_DIM_INCH", "inches");
        var1.put("MDC_DIM_SQ_M", "m2");
        var1.put("MDC_DIM_MILLI_VOLT", "millivolts");
        var1.put("MDC_DIM_DEGC", "DegreesCelsius");
        var1.put("MDC_DIM_FAHR", "DegreesFahrenheit");
        var1.put("MDC_DIM_RESP_PER_MIN", "Respirations/Minute");
        var1.put("MDC_DIM_L_PER_MIN", "l*min-1");
        var1.put("MDC_DIM_L_PER_MIN_PER_M_SQ", "l*min-1*m-2");
        var1.put("MDC_DIM_PER_L_PER_MIN", "1/(min*L)");
        var1.put("MDC_DIM_PER_MIN", "min-1");
        var1.put("MDC_DIM_OHM", "Ohms(Ω)");
        var1.put("MDC_DIM_CM_H2O", "cmH2O");
        var1.put("MDC_DIM_CM_H2O_PER_L", "cmH2O/L");
        var1.put("MNDRY_DIM_CM_H2O_SEC", "cmH2O*s");
        var1.put("MDC_DIM_CM_H2O_PER_L_PER_SEC", "cmH2O/L/s");
        var1.put("MDC_DIM_MILLI_L_PER_CM_H2O", "mL/cmH2O");
        var1.put("MDC_DIM_MILLI_L", "ml");
        var1.put("MDC_DIM_MILLI_L_PER_KG", "ml/kg");
        var1.put("MDC_DIM_MILLI_L_PER_MIN", "ml/min");
        var1.put("MDC_DIM_MILLI_L_PER_M_SQ", "ml/m2");
        var1.put("MDC_DIM_MILLI_L_PER_MIN_PER_M_SQ", "ml/min/m2");
        var1.put("MNDRY_DIM_MILLI_L_PER_MIN_PER_KG", "ml/min/kg");
        var1.put("MDC_DIM_MILLI_L_PER_HR", "ml/h");
        var1.put("MNDRY_DIM_MILLI_L_PER_HECTO_PASCAL", "ml/hPa");
        var1.put("MNDRY_DIM_HECTO_PASCAL_PER_L_PER_SEC", "hPa/l/s");
        var1.put("MDC_DIM_DECIBEL", "DB");
        var1.put("MNDRY_DIM_DYNE_SEC_PER_CM5", "DS/cm5");
        var1.put("MDC_DIM_DYNE_SEC_PER_M_SQ_PER_CM_5", "DS*m-2/cm5");
        var1.put("MDC_DIM_HZ", "hz");
        var1.put("MDC_DIM_MIN", "min");
        var1.put("MDC_DIM_SEC", "Second(s)");
        var1.put("MDC_DIM_MILLI_SEC", "ms");
        var1.put("MDC_DIM_JOULES", "J");
        var1.put("MNDRY_DIM_JOULES_PER_L", "J/L");
        var1.put("MNDRY_DIM_JOULES_PER_MIN", "J/min");
        var1.put("MNDRY_DIM_PER_KILO_OHM", "/kΩ");
        var1.put("MNDRY_DIM_PER_HECTO_SEC_SQ", "/100s2");
        var1.put("MDC_DIM_PER_KILO_SEC", "/1000s");
        var1.put("MDC_DIM_KILO_G_M", "kg*m");
        var1.put("MDC_DIM_KILO_G_M_PER_M_SQ", "kg*m/m2");
        var1.put("MDC_DIM_G_M", "g*m");
        var1.put("MDC_DIM_G_M_PER_M_SQ", "g*m/m2");
        var1.put("MDC_DIM_WATT", "W");
        var1.put("MNDRY_DIM_WATT_PER_M_SQ", "W/m2");
        var1.put("MNDRY_DIM_MMHG_PER_SEC", "mmHg/s");
        var1.put("MDC_DIM_G_PER_DL", "g/dl");
        var1.put("MDC_DIM_BREATHS_PER_MIN_PER_L", "rpm/l");
        var1.put("MDC_DIM_DIMLESS", "-");
        var1.put("MDC_DIM_MILLI_OHM", "mΩ");
        var1.put("MDC_DIM_MICRO_VOLT", "μv");
        var1.put("MNDRY_DIM_KILO_PASCAL_SEC_PER_L", "kPa*s/l");
        var1.put("MNDRY_DIM_KILO_PASCAL_SEC_M_SQ_PER_L", "kPa*s*m2/l");
        var1.put("MNDRY_DIM_MILLI_BAR_SEC", "mbar*s");
        var1.put("MNDRY_DIM_HECTO_PASCAL_SEC", "hPa*s");
        var1.put("MDC_DIM_MILLI_WATT", "mW");
        var1.put("MDC_DIM_MILLI_MOLE_PER_L", "mmol/L");
        var1.put("MDC_DIM_MILLI_G_PER_DL", "mg/dL");
        var1.put("MDC_DIM_L", "L");
        var1.put("MNDRY_DIM_MIN_PERCENT", "min*%");
        var1.put("MDC_DIM_MILLI_L_PER_BEAT", "ml*beat-1");
        var1.put("MNDRY_DIM_MILLI_L_PER_BEAT_PER_M_SQ", "ml*beat-1*m2");
        var1.put("MNDRY_DIM_CUSTOM_UNIT1", "custom_unit1");
        var1.put("MNDRY_DIM_CUSTOM_UNIT2", "custom_unit2");
        var1.put("MNDRY_DIM_CUSTOM_UNIT3", "custom_unit3");
        var1.put("MDC_DIM_ANG_DEG", "angle");
        var1.put("MDC_DIM_ANG_RAD", "radian");
        var1.put("MNDRY_DIM_CM_H2O_PER_SEC", "cmH2O/s");
        var1.put("MDC_DIM_G_PER_L", "g/l");
        var1.put("MDC_DIM_AMPS", "Amperes(A)");
        var1.put("MDC_DIM_MILLI_AMPS", "milliamperes(mA)");
        var1.put("MDC_DIM_PARTS_PER_10_TO_MINUS_6", "Part(s)");
        var1.put("MDC_DIM_PER_SEC", "dim/sec");
        var1.put("MDC_DIM_YR", "year");
        var1.put("MDC_DIM_VOL_PERCENT_PER_L", "%/L");
        var1.put("MDC_DIM_MILLI_BAR_PER_L", "mbar/L");
        var1.put("MDC_DIM_MICRO_AMPS", "uA");
        var1.put("MDC_DIM_MON", "month");
        var1.put("MDC_DIM_DAY", "day");
        var1.put("MDC_DIM_HR", "hour");
        var1.put("MDC_DIM_CENTI_L", "cL");
        var1.put("MNDRY_DIM_COMPRESSIONS_PER_MIN", "cpm");
        return (String) var1.get(var0);
    }

    public Message getMindrayMessage(String var1, File var2) throws ParserConfigurationException, SAXException, IOException {
        SAXParser var3 = SAXParserFactory.newInstance().newSAXParser();
        MindrayConfigHandler var4 = new MindrayConfigHandler(var1);
        XMLReader var5;
        (var5 = var3.getXMLReader()).setContentHandler(var4);
        var5.parse(String.valueOf(var2));
        return var4.a;
    }

    public String MessagedJson(Message var1) {
        JsonObject var3 = new JsonObject();
        JsonArray var4 = new JsonArray();
        JsonObject var2;
        (var2 = new JsonObject()).addProperty(((Field) ((Segment) var1.Segments.get(0)).Fields.get(2)).name, ((Field) ((Segment) var1.Segments.get(0)).Fields.get(2)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(0)).Fields.get(6)).name, ((Field) ((Segment) var1.Segments.get(0)).Fields.get(6)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(0)).Fields.get(7)).name, var1.type);
        var4.add(var2);
        var2 = new JsonObject();
        String[] var5;
        String var6 = (var5 = ((Field) ((Segment) var1.Segments.get(1)).Fields.get(0)).realValue.replace("^", ",").split(","))[0];
        String var10 = var5[3];
        var2.addProperty("PatientID", var6);
        var2.addProperty("AssigningAuthority", var10);
        var5 = ((Field) ((Segment) var1.Segments.get(1)).Fields.get(1)).realValue.replace("^", ",").split(",");
        var10 = var5[0] + var5[1];
        var2.addProperty("Patientname", var10);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(1)).Fields.get(3)).name, ((Field) ((Segment) var1.Segments.get(1)).Fields.get(3)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(1)).Fields.get(4)).name, ((Field) ((Segment) var1.Segments.get(1)).Fields.get(4)).realValue);
        var4.add(var2);
        (var2 = new JsonObject()).addProperty(((Field) ((Segment) var1.Segments.get(2)).Fields.get(0)).name, ((Field) ((Segment) var1.Segments.get(2)).Fields.get(0)).realValue);
        var6 = (var5 = ((Field) ((Segment) var1.Segments.get(2)).Fields.get(1)).realValue.replace("^", ",").split(","))[0];
        String var7 = var5[1];
        String var8 = var5[2];
        var10 = var5[3];
        var2.addProperty("Hospital_department", var6);
        var2.addProperty("Room", var7);
        var2.addProperty("Bed", var8);
        var2.addProperty("Facility", var10);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(2)).Fields.get(2)).name, ((Field) ((Segment) var1.Segments.get(2)).Fields.get(2)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(2)).Fields.get(3)).name, ((Field) ((Segment) var1.Segments.get(2)).Fields.get(3)).realValue);
        var4.add(var2);
        (var2 = new JsonObject()).addProperty(((Field) ((Segment) var1.Segments.get(3)).Fields.get(0)).name, ((Field) ((Segment) var1.Segments.get(3)).Fields.get(0)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(3)).Fields.get(3)).name, ((Field) ((Segment) var1.Segments.get(3)).Fields.get(3)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(3)).Fields.get(4)).name, ((Field) ((Segment) var1.Segments.get(3)).Fields.get(4)).realValue);
        var4.add(var2);
        JsonObject var12;
        (var12 = new JsonObject()).addProperty(((Field) ((Segment) var1.Segments.get(4)).Fields.get(0)).name, ((Field) ((Segment) var1.Segments.get(4)).Fields.get(0)).realValue);
        var12.addProperty(((Field) ((Segment) var1.Segments.get(4)).Fields.get(1)).name, ((Field) ((Segment) var1.Segments.get(4)).Fields.get(1)).realValue);
        var12.addProperty(((Field) ((Segment) var1.Segments.get(4)).Fields.get(2)).name, ((Field) ((Segment) var1.Segments.get(4)).Fields.get(2)).realValue);
        String var9 = Arrays.toString(((Field) ((Segment) var1.Segments.get(4)).Fields.get(4)).realValue.replace("^", ",").split(","));
        String[] var11 = ((Field) ((Segment) var1.Segments.get(4)).Fields.get(2)).realValue.replace("^", ",").split(",");
        var12.addProperty(var11[1], var9);
        var9 = ((Field) ((Segment) var1.Segments.get(4)).Fields.get(5)).realValue.replace("^", ",").split(",")[1];
        var12.addProperty(((Field) ((Segment) var1.Segments.get(4)).Fields.get(5)).name, a(var9));
        var4.add(var12);
        (var2 = new JsonObject()).addProperty(((Field) ((Segment) var1.Segments.get(5)).Fields.get(0)).name, ((Field) ((Segment) var1.Segments.get(5)).Fields.get(0)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(5)).Fields.get(1)).name, ((Field) ((Segment) var1.Segments.get(5)).Fields.get(1)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(5)).Fields.get(2)).name, ((Field) ((Segment) var1.Segments.get(5)).Fields.get(2)).realValue);
        var5 = ((Field) ((Segment) var1.Segments.get(5)).Fields.get(2)).realValue.replace("^", ",").split(",");
        var2.addProperty(var5[1], ((Field) ((Segment) var1.Segments.get(5)).Fields.get(4)).realValue.replace("^", ","));
        var10 = ((Field) ((Segment) var1.Segments.get(5)).Fields.get(5)).realValue.replace("^", ",").split(",")[1];
        var2.addProperty(((Field) ((Segment) var1.Segments.get(5)).Fields.get(5)).name, a(var10));
        var4.add(var2);
        (var2 = new JsonObject()).addProperty(((Field) ((Segment) var1.Segments.get(6)).Fields.get(0)).name, ((Field) ((Segment) var1.Segments.get(6)).Fields.get(0)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(6)).Fields.get(1)).name, ((Field) ((Segment) var1.Segments.get(6)).Fields.get(1)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(6)).Fields.get(2)).name, ((Field) ((Segment) var1.Segments.get(6)).Fields.get(2)).realValue);
        var5 = ((Field) ((Segment) var1.Segments.get(6)).Fields.get(2)).realValue.replace("^", ",").split(",");
        var2.addProperty(var5[1], ((Field) ((Segment) var1.Segments.get(6)).Fields.get(4)).realValue.replace("^", ","));
        var10 = ((Field) ((Segment) var1.Segments.get(6)).Fields.get(5)).realValue.replace("^", ",").split(",")[1];
        var2.addProperty(((Field) ((Segment) var1.Segments.get(6)).Fields.get(5)).name, a(var10));
        var4.add(var2);
        (var2 = new JsonObject()).addProperty(((Field) ((Segment) var1.Segments.get(7)).Fields.get(0)).name, ((Field) ((Segment) var1.Segments.get(7)).Fields.get(0)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(7)).Fields.get(1)).name, ((Field) ((Segment) var1.Segments.get(7)).Fields.get(1)).realValue);
        var2.addProperty(((Field) ((Segment) var1.Segments.get(7)).Fields.get(2)).name, ((Field) ((Segment) var1.Segments.get(7)).Fields.get(2)).realValue);
        var5 = ((Field) ((Segment) var1.Segments.get(7)).Fields.get(2)).realValue.replace("^", ",").split(",");
        var2.addProperty(var5[1], ((Field) ((Segment) var1.Segments.get(7)).Fields.get(4)).realValue);
        var4.add(var2);
        var3.add("MindrayN1", var4);
        return var3.toString();
    }
}
